package model;

import java.util.StringTokenizer;

import battleship.ConfigureGame;

public class Submarine extends UnArmoredShip 
{

	public Submarine() 
	{
		super(ConfigureGame.SHIP_NR_BLOCKS[ConfigureGame.SUBMARINE_ID]);
		this.ship_ID = ConfigureGame.SUBMARINE_ID;
	}
	
	@Override
	protected void readOtherCoordinatesFromFile(StringTokenizer st)
	{
		int x = Integer.parseInt(st.nextToken());
		int y = Integer.parseInt(st.nextToken());
		System.out.println(x+" "+y);
		this.coord.add(new Point(x,y));
	}
	
	@Override
    protected void addOtherBlock(BlockInterface[][] table)
	{
		if( table[this.coord.get(0).getX()-1][this.coord.get(0).getY()-1] == null)
			table[this.coord.get(0).getX()-1][this.coord.get(0).getY()-1] = new Block(this,this.ship_nr_of_blocks - 1);
		else
			table[this.coord.get(0).getX()-1][this.coord.get(0).getY()-1].addShip(this, this.ship_nr_of_blocks - 1);
		this.components[this.ship_nr_of_blocks-1] = table[this.coord.get(0).getX()-1][this.coord.get(0).getY()-1];
	}
	
	@Override
	protected boolean otherCoordinatesNOK()
	{
		if( (ConfigureGame.LOWER_BOUNDARY>this.coord.get(0).getX() || ConfigureGame.HIGHER_BOUNDARY<this.coord.get(0).getX() || ConfigureGame.LOWER_BOUNDARY>this.coord.get(0).getY() || ConfigureGame.HIGHER_BOUNDARY<this.coord.get(0).getY()) )
			return true;
		return false;
	}
	
	@Override
	protected int otherBlock()
	{
		return 1;
	}
	
}
